const mongoose = require("mongoose");

mongoose.connect("mongodb://127.0.0.1:27017/yang", { useNewUrlParser: true }, (err) => {
    if (err) {
        console.log(err);
        return;
    }
    console.log("mongo连接成功");
});

var Schema = mongoose.Schema;

var ObjectId = Schema.Types.ObjectId;

var NewsSchema = new Schema({
    cid: {
        type: ObjectId,
        ref: "NewsCate"
    },
    title: String,
    uid: {
        type: ObjectId,
        ref: "Users"
    },
    Datetime: String
});

module.exports = mongoose.model("News", NewsSchema, "News");